package Studing;

import javax.swing.tree.TreeNode;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Vector;

/**
 * @ClassName Test
 * @Description: TODO
 * @Author hl
 * @Date 2020/5/25
 * @Version V1.0
 **/

class BinaryTreeNode {

    public int m_nValue;

    public BinaryTreeNode m_pLeft;

    public BinaryTreeNode m_pRight;

}
public class Test {
/*
    BinaryTreeNode head = null; //定义链表当前结点
    BinaryTreeNode realHead = null; //定义链表头部的结点
    //中序递归遍历修改链表指针即可实现
    public BinaryTreeNode convert(BinaryTreeNode pRootOfTree){
        if(pRootOfTree == null){
            return null;
        }
        convert(pRootOfTree.m_pLeft); //左

        if(head == null){ //根
            head = pRootOfTree;
            realHead = pRootOfTree;
        }else{
            head.m_pRight = pRootOfTree;
            pRootOfTree.m_pLeft = head;
            head = pRootOfTree;
        }

        convert(pRootOfTree.m_pRight); //右
        return realHead;
    }*/

    public BinaryTreeNode Convert(BinaryTreeNode pRootOfTree) {
        if(pRootOfTree==null||(pRootOfTree.m_pLeft==null&&pRootOfTree.m_pRight==null)){
            return pRootOfTree;
        }
        //将左子树构造成双链表
        BinaryTreeNode left=Convert(pRootOfTree.m_pLeft);
        BinaryTreeNode p=left;
        //找到左链表的最后一个非空节点
        while(p!=null&&p.m_pRight!=null){
            p=p.m_pRight;
        }
        if(left!=null){
            p.m_pRight=pRootOfTree;
            pRootOfTree.m_pLeft=p;

        }
        BinaryTreeNode right=Convert(pRootOfTree.m_pRight);
        if(right!=null){
            pRootOfTree.m_pRight=right;
            right.m_pLeft=pRootOfTree;

        }
        return left!=null?left:pRootOfTree;

    }

    //main方法测试
    public static void main(String[] args) {
/*        Test m2 = new Test();
        BinaryTreeNode node1 = new BinaryTreeNode();
        node1.m_nValue = 1;

        BinaryTreeNode node2= new BinaryTreeNode();
        node2.m_nValue = 2;

        BinaryTreeNode node3 = new BinaryTreeNode();
        node3.m_nValue = 3;

        node2.m_pLeft = node1;
        node2.m_pRight = node3;
        BinaryTreeNode head = m2.Convert(node2);
        System.out.println(head.m_nValue);
        System.out.println(head.m_pRight.m_nValue);
        System.out.println(head.m_pRight.m_pRight.m_nValue);*/

        String result="asdadad";
        System.out.println(result.substring(1));



    }



}
